package cn.itcast.demo.lock;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author 虎哥
 */
@Component
public class RedisLockFactory {

    private final StringRedisTemplate redisTemplate;

    public RedisLockFactory(StringRedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    public SimpleRedisLock getSimpleRedisLock(String key){
        return new SimpleRedisLock(key, redisTemplate);
    }

    public ReentrantRedisLock getReenTrantRedisLock(String key){
        return new ReentrantRedisLock(key, redisTemplate);
    }
}
